//
//  YAYIAvatarCell.m
//  YAYIDoctor
//
//  Created by hxp on 16/4/29.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYIAvatarCell.h"

@implementation YAYIAvatarCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCustomView];
//        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return self;
}
-(void)createCustomView
{
    self.avatar = [UIImageView new];
    self.avatar.clipsToBounds = YES;
    self.avatar.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:self.avatar];
    
    self.name = [UILabel new];
    self.name.textColor = [UIColor blackColor];
    self.name.font = [UIFont systemFontOfSize:font16];
    [self.contentView addSubview:self.name];
    
    self.phone = [UILabel new];
    self.phone.textColor = [UIColor lightGrayColor];
    self.phone.font = [UIFont systemFontOfSize:font14];
    [self.contentView addSubview:self.phone];
    
    self.icon = [UIImageView new];
    self.icon.image = [UIImage imageNamed:@"Icon_1"];
    [self.contentView addSubview:self.icon];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.avatar.layer.cornerRadius = 68/2.0;
    [self.avatar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(20));
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(68, 68));
    }];
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.avatar.mas_right).with.offset(30);
        make.bottom.mas_equalTo(self.avatar.mas_centerY).with.offset(-4);
        make.size.mas_equalTo(CGSizeMake(180, 18));
    }];
    [self.phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.name.mas_left);
        make.top.mas_equalTo(self.avatar.mas_centerY).with.offset(4);
        make.size.mas_equalTo(CGSizeMake(240, 18));
    }];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView).with.offset(-14);
        make.centerY.mas_equalTo(self.contentView).with.offset(0);
        make.size.mas_equalTo(CGSizeMake(7, 12));
    }];
}
@end
